import java.util.Scanner;

public class Test {
}

// 注意类名必须为 Main, 不要有任何 package xxx 信息
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            if(s1.length()>s2.length()){
                String s = s1;
                s1 = s2;
                s2 = s;
            }
            int n = s1.length();
            int m = s2.length();
            int[][] dp = new int[n+1][m+1];
            int max = 0;
            for(int i=1; i<=n; i++){
                for(int j=1; j<=m; j++){
                    if(s1.charAt(i-1)==s2.charAt(j-1)){
                        dp[i][j] = dp[i-1][j-1]+1;
                        if(max < dp[i][j]){
                            max = dp[i][j];
                        }
                    }
                }
            }
            System.out.println(max);
        }
    }
}
